<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cmccsi.mapper.qxdeptMemberDtoMapper">
	<resultMap id="BaseResultMap" type="com.cmccsi.entity.qxdeptMemberDto">
		<id column="id" property="id" jdbcType="BIGINT" />
		<result column="dept_id" property="deptId" jdbcType="BIGINT" />
		<result column="user_id" property="userId" jdbcType="BIGINT" />
		<result column="status" property="status" jdbcType="INTEGER" />
		<result column="position" property="position" jdbcType="VARCHAR" />
		<result column="title" property="title" jdbcType="VARCHAR" />
		<result column="sort" property="sort" jdbcType="INTEGER" />
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
		<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
	</resultMap>
	<resultMap id="MemberIdsResultMap" type="java.lang.Long">
		<id column="user_id" property="userId" jdbcType="BIGINT" />
	</resultMap>
	<sql id="Base_Column_List">
		id, dept_id, user_id, status, position, title, sort, create_time,
		update_time
	</sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
		parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List" />
		from qxdept_member
		where id = #{id,jdbcType=BIGINT}
	</select>
	<select id="selectMemberIdsByDeptId" resultMap="MemberIdsResultMap" parameterType="java.lang.Long">
		select user_id
		from qxdept_member
		where dept_id = #{deptId,jdbcType=BIGINT}
	</select>

	<delete id="deleteByDeptId" parameterType="java.lang.Long">
		delete from qxdept_member
		where dept_id = #{deptId,jdbcType=BIGINT}
	</delete>

	<delete id="deleteByDeptidAndMemberids">
		delete from qxdept_member
		where dept_id = #{activityId} and user_id in
		<foreach item="item" index="index" collection="userIds" open="("
			separator="," close=")">
			#{item}
		</foreach>
	</delete>


	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
		delete from qxdept_member
		where id = #{id,jdbcType=BIGINT}
	</delete>
	<insert id="insert" parameterType="com.cmccsi.entity.qxdeptMemberDto">
		insert into qxdept_member (id, dept_id, user_id,
		status, position, title,
		sort, create_time, update_time
		)
		values (#{id,jdbcType=BIGINT}, #{deptId,jdbcType=BIGINT},
		#{userId,jdbcType=BIGINT},
		#{status,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
		#{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
		#{updateTime,jdbcType=TIMESTAMP}
		)
	</insert>
	<insert id="insertSelective" parameterType="com.cmccsi.entity.qxdeptMemberDto">
		insert into qxdept_member
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="id != null">
				id,
			</if>
			<if test="deptId != null">
				dept_id,
			</if>
			<if test="userId != null">
				user_id,
			</if>
			<if test="status != null">
				status,
			</if>
			<if test="position != null">
				position,
			</if>
			<if test="title != null">
				title,
			</if>
			<if test="sort != null">
				sort,
			</if>
			<if test="createTime != null">
				create_time,
			</if>
			<if test="updateTime != null">
				update_time,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="id != null">
				#{id,jdbcType=BIGINT},
			</if>
			<if test="deptId != null">
				#{deptId,jdbcType=BIGINT},
			</if>
			<if test="userId != null">
				#{userId,jdbcType=BIGINT},
			</if>
			<if test="status != null">
				#{status,jdbcType=INTEGER},
			</if>
			<if test="position != null">
				#{position,jdbcType=VARCHAR},
			</if>
			<if test="title != null">
				#{title,jdbcType=VARCHAR},
			</if>
			<if test="sort != null">
				#{sort,jdbcType=INTEGER},
			</if>
			<if test="createTime != null">
				#{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="updateTime != null">
				#{updateTime,jdbcType=TIMESTAMP},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="com.cmccsi.entity.qxdeptMemberDto">
		update qxdept_member
		<set>
			<if test="deptId != null">
				dept_id = #{deptId,jdbcType=BIGINT},
			</if>
			<if test="userId != null">
				user_id = #{userId,jdbcType=BIGINT},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=INTEGER},
			</if>
			<if test="position != null">
				position = #{position,jdbcType=VARCHAR},
			</if>
			<if test="title != null">
				title = #{title,jdbcType=VARCHAR},
			</if>
			<if test="sort != null">
				sort = #{sort,jdbcType=INTEGER},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="updateTime != null">
				update_time = #{updateTime,jdbcType=TIMESTAMP},
			</if>
		</set>
		where id = #{id,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.cmccsi.entity.qxdeptMemberDto">
		update qxdept_member
		set dept_id = #{deptId,jdbcType=BIGINT},
		user_id = #{userId,jdbcType=BIGINT},
		status = #{status,jdbcType=INTEGER},
		position = #{position,jdbcType=VARCHAR},
		title = #{title,jdbcType=VARCHAR},
		sort = #{sort,jdbcType=INTEGER},
		create_time = #{createTime,jdbcType=TIMESTAMP},
		update_time = #{updateTime,jdbcType=TIMESTAMP}
		where id = #{id,jdbcType=BIGINT}
	</update>
</mapper>